1118A - Water Buying - CodeForces Solution


math *800

Please click on ads to support us..

Python Code:

t = int(input())
for _ in range(t):
    n, a, b = (int(i) for i in input().split())
    res = min(n*a, (n // 2) * b + (n % 2) * a)
    print(res)

C++ Code:

#include <bits/stdc++.h>

using namespace std;

int main()
{   
    int t;
    cin>>t;
    while(t--){
       long long a,b,c;
       cin>>a>>b>>c;
       long long sum1,sum2;
       sum1=a*b;
       sum2=(a/2)*c;
       if(a%2!=0)
       sum2+=b;
       
       cout<<min(sum1,sum2)<<endl;
        
        
        
        
        
    }
        
        

}


Comments

Submit
0 Comments
More Questions

1729B - Decode String
1729C - Jumping on Tiles
1729E - Guess the Cycle Size
553B - Kyoya and Permutation
1729D - Friends and the Restaurant
1606C - Banknotes
580C - Kefa and Park
342A - Xenia and Divisors
1033A - King Escape
39D - Cubical Planet
1453A - Cancel the Trains
645A - Amity Assessment
1144A - Diverse Strings
1553B - Reverse String
1073A - Diverse Substring
630N - Forecast
312B - Archer
34D - Road Map
630I - Parking Lot
160B - Unlucky Ticket
371B - Fox Dividing Cheese
584B - Kolya and Tanya
137B - Permutation
550C - Divisibility by Eight
5A - Chat Servers Outgoing Traffic
615A - Bulbs
5B - Center Alignment
549A - Face Detection
535B - Tavas and SaDDas
722C - Destroying Array